package kr.hkit.powerjava.chapter14;

import java.awt.Component;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

class MyFrame2 extends JFrame{
	public MyFrame2(){
		setTitle("BoxLayoutTest");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		JPanel panel = new JPanel();
		
		panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
		
		makeButton(panel, "button1");
		makeButton(panel, "b2");
		makeButton(panel, "b3");
		makeButton(panel, "b4");
		makeButton(panel, "b5");
		
		add(panel);
		pack();
		setVisible(true);
	}

	private void makeButton(JPanel panel, String text) {
		JButton button = new JButton(text);
		button.setAlignmentX(Component.CENTER_ALIGNMENT);
		panel.add(button);
		
	}
}
public class BoxTest {
	public static void main(String[] args) {
		MyFrame2 f2 = new MyFrame2();
	}
}
